<?php
include '../conn.php';
//获取商品id
$goods_id = $_REQUEST['gid'];

$sql = "select * from goods where id = ".$goods_id;
?>
<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>商品编辑</title>

    <!-- Bootstrap core CSS -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">

    <link href="./css/navbar-fixed-top.css" rel="stylesheet">

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">后台管理</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li><a href="/admin/main.php">首页</a></li>
            <li class="active"><a href="/admin/goodslist.php">商品管理</a></li>
            <li><a href="/admin/userlist.php">用户管理</a></li>
            <li><a href="/admin/articlelist.php">通知管理</a></li>
            <li><a href="/admin/advlist.php">轮播管理</a></li>
            <li><a href="/admin/orderlist.php">订单管理</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="/index.php">进入前台 <span class="sr-only">(current)</span></a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">


<br><br><br><br>
        <table class="table table-striped">
        <thead>
          <tr>
            <th colspan="2">商品编辑</th>

          </tr>
        </thead>
        <tbody>
          <form class="" action="doeditgoods.php?gid=<?php echo $goods_id?>" method="post"enctype="multipart/form-data">
          <?php
          

          $result = $conn->query($sql);

          if ($result->num_rows>0) {
            //存在该商品
            while ($row=$result->fetch_assoc()) {
              
?>


    <tr>
      <td>商品名称</td>
      <td><input type="text" name="goodsname" value="<?php echo $row['goods_name']?>"></td>
    </tr>

    <tr>
      <td>类型</td>
      
      <td><input type="text" name="type" value="<?php echo $row['type'];?>"></td>
    </tr>

    <tr>
      <td>旧价格</td>
      <td><input type="text" name="oldprice" value="<?php echo $row['old_price']?>"></td>
    </tr>

    <tr>
      <td>当前价格</td>
      <td><input type="text" name="price" value="<?php echo $row['price']?>"></td>
    </tr>

    <tr>
      <td>库存</td>
      <td><input type="text" name="sum" value="<?php echo $row['sum']?>"></td>
    </tr>
    <tr>
      <td>商品描述</td>
      <td><input type="text" name="desc" value="<?php echo $row['description']?>"></td>
    </tr>

    <tr>
      <td>商品图片地址</td>
      <td><input type="text" name="picture" value="<?php echo $row['picture']?>"></td>
    </tr>

    <tr>
      <td></td>
      <td><input type="submit" class="btn btn-info" name="" value="更新"></td>
    </tr>
    <?php


  }
  }else{
  echo "不存在该商品！";
  }
     ?>
  </form>
    </tbody>
  </table>
    </div> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
    <script src="./js/bootstrap.min.js"></script>
    
  </body>
</html>
